package ModelLayer;
import java.util.*;
public class OrderList
{
    public static HashMap<Integer,Order> orderlist;
    private static OrderList instance=null;

    public OrderList()
    {orderlist=new HashMap<Integer,Order>();}

    public static OrderList getInstance() { 
        if(instance == null) 
            instance = new OrderList(); 
        return instance; 
    }
    
    public static int getNoOrdersStaff(String name)
    {
    	int count=0;
    	
    	for(Integer key : orderlist.keySet())
    	{
    		if(orderlist.get(key).getEmployee().getName().equals(name)) count++;
    	}
    	
    	return count;
    }
    
    
    public void addOrder(Order order) {
        orderlist.put((Integer)order.getId(), order);
    }

    public void deleteOrder(int id) {
        if(orderlist.containsKey(id)) {
            orderlist.remove(id);
        }
    }

    public Order getOrder(int id) {
        if(orderlist.containsKey(id)) {
            return orderlist.get(id);
        }
        return null;
    }
    
    public Iterator getOrdersIterator()
    {
    	return orderlist.values().iterator();
    }
    
    public int getOrdersSize() { return orderlist.size(); }

}
